package com.train.streamsend.controller;

import com.train.streamsend.rabbitsend.SendMessage;
import com.train.streamsend.rabbitsend.SendMessage1Impl;
import com.train.streamsend.rabbitsend.SendMessage2Impl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping(path = {"/send"})
public class SendController {
    @Resource
    SendMessage1Impl sendMessage1;
    @Resource
    SendMessage2Impl sendMessage2;

    @GetMapping(path = {"/{f}/{str}"})
    public String send(@PathVariable("f") Integer flag,  @PathVariable("str") String msg){
        return flag == 1 ? sendMessage1.send(msg):sendMessage2.send(msg);
    }
}
